﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace SimpleRadar.GUI
{
    public partial class PageSettings : PhoneApplicationPage
    {
        public PageSettings()
        {
            InitializeComponent();
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            InitializeSettings();
        }
        private void InitializeSettings()
        {
            ViewModel.IsChecked = Global.setting.AreaView;
            AllowMyLocation.IsChecked = Global.setting.ViewLocation;
            RadaZoom.Value =Math.Abs(Global.setting.RadaZoom-9);
        }

        private void ViewMode_checked(object sender, RoutedEventArgs e)
        {
            Global.setting.AreaView = true;
        }

        private void ViewModel_Unchecked(object sender, RoutedEventArgs e)
        {
            Global.setting.AreaView = false;
        }

        private void PhoneApplicationPage_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (RadaZoom != null)
            {
                Global.setting.RadaZoom = 9 - RadaZoom.Value;
            }
            Global.setting.SaveSettings();
        }

        private void RadaZoom_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            
        }

        private void AllowMyLocation_Checked(object sender, RoutedEventArgs e)
        {
            Global.setting.ViewLocation = true;

           // App.StartAgent();
        }

        private void AllowMyLocation_Unchecked(object sender, RoutedEventArgs e)
        {
            Global.setting.ViewLocation = false;
//
          //  App.StopAgentIfStarted();
        }

        private void DisableRadar_Checked(object sender, RoutedEventArgs e)
        {
            Global.setting.RadaSearch = true;
        }

        private void DisableRadar_Unchecked(object sender, RoutedEventArgs e)
        {
            Global.setting.RadaSearch = false;
        }
    }
}